package com.piepesken.mediscale.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp

@Composable
fun StatisticCard(
    title: String,
    value: Int,
    unit: String,
    textColor: Color,
    backgroundColor: Color,
    icon: ImageVector
) {
    val configuration = LocalConfiguration.current
    val screenWidth = configuration.screenWidthDp
    val screenHeight = configuration.screenHeightDp

    val padding = 8

    Box(
        modifier = Modifier
            .width(
                screenWidth
                    .div(2)
                    .minus(padding).dp
            )
            .height(
                screenHeight
                    .div(5)
                    .minus(padding).dp
            )
            .padding(8.dp)
            .background(
                color = backgroundColor,
                RoundedCornerShape(15)
            )
    ) {
        Column(
            modifier = Modifier.padding(top = 16.dp, start = 16.dp)
        ) {
            Row(
                horizontalArrangement = Arrangement.Center,
                verticalAlignment = Alignment.CenterVertically,
                modifier = Modifier.padding(start = 4.dp, bottom = 32.dp)
            ) {
                Icon(
                    imageVector = icon,
                    contentDescription = title,
                    tint = textColor,
                    modifier = Modifier.size(24.dp)
                )

                Text(
                    text = title,
                    color = textColor,
                    fontSize = MaterialTheme.typography.titleLarge.fontSize,
                    fontWeight = FontWeight.SemiBold,
                    fontStyle = MaterialTheme.typography.titleLarge.fontStyle,
                    modifier = Modifier.padding(8.dp).padding(start = 2.dp)
                )
            }

            Row(
                horizontalArrangement = Arrangement.Start,
                verticalAlignment = Alignment.CenterVertically,
                modifier = Modifier.padding(start = 4.dp, bottom = 16.dp)
            ) {
                Text(
                    color = textColor,
                    fontStyle = MaterialTheme.typography.displayLarge.fontStyle,
                    fontSize = MaterialTheme.typography.displayLarge.fontSize,
                    modifier = Modifier.padding(end = 8.dp).alignByBaseline(),
                    text = value.toString()
                )

                Text(
                    color = textColor,
                    fontStyle = MaterialTheme.typography.displaySmall.fontStyle,
                    fontSize = MaterialTheme.typography.displaySmall.fontSize,
                    modifier = Modifier.alignByBaseline(),
                    text = unit
                )
            }
        }


    }
}

//
//@Composable
//fun GeneratedCode(fonts: FontFamily, fonts: FontFamily) {
//    Box(
//        contentAlignment = Alignment.Center,
//        modifier = Modifier
//            .width(width = 239.dp)
//            .height(height = 80.dp)
//            .padding(start = 23.dp,
//                end = 17.dp,
//                top = 18.dp,
//                bottom = 18.dp)
//    ) {
//        Box(
//            contentAlignment = Alignment.CenterStart,
//            modifier = Modifier
//                .width(width = 50.dp)
//                .height(height = 44.dp)
//                .padding(horizontal = 13.dp,
//                    vertical = 10.dp)
//        ) {
//            Image(
//                painter = painterResource(id = R.drawable.mdi:arm-flex),
//                contentDescription = "mdi:arm-flex",
//                colorFilter = ColorFilter.tint(Color(0xff323232)),
//                modifier = Modifier
//                    .size(size = 24.dp))
//        }
//        Text(
//            text = "14",
//            color = Color(0xff323232),
//            fontFamily = fonts,
//            lineHeight = 20.sp,
//            style = TextStyle(
//                fontSize = 18.sp))
//        Text(
//            text = "Beginner Exercises",
//            color = Color(0xff838383),
//            fontFamily = fonts,
//            lineHeight = 20.sp,
//            style = TextStyle(
//                fontSize = 14.sp))
//    }
//}